<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<c:url value="/resources/css/view.css"/>" >
</head>
<body> 
 
<h1>Orders</h1>
<table style="text-align: right;">
<tr>
  <th width="100">Order Id</th>
  <th width="200">Total Price</th>
  <th width="150">Order Date </th>
  </tr>
 <c:forEach var="orderLine" items="${orderLines}" varStatus="status">
  <tr>
   <c:url var="viewUrl" value="/order/view" >
 		<c:param name="orderId" value="${orderLine.orderId}" />
   </c:url>
   <td><a href='<c:out value="${viewUrl}"/>'>${orderLine.orderId}</a></td>

   <td><c:out value="${orderLine.totalPrice/100}" /></td>
	<fmt:formatDate value="${orderLine.orderDate}" var="dateString" pattern="dd-MM-yyyy HH:mm" />
   <td><c:out value="${dateString}" /></td>
   <c:url var="statusUrl" value="/order/status" >
		<c:param name="orderId" value= "${orderLine.orderId}" />
    </c:url>
    	<td><a href='<c:out value="${statusUrl}"/>'>status</a></td>	
   
  </tr>
 </c:forEach>
<tr ><td></td><td></td><td><a href="<c:url value="/home"/>">home</a></td></tr >
</table>
<c:if test="${lastPageNum>1}">
<c:forEach var="i" begin="1" end="${lastPageNum}" varStatus="status">
	<c:url var="pageUrl" value="/order" >
		<c:param name="pageNum" value= "${i}" />
    </c:url>
    	<td><a href='<c:out value="${pageUrl}"/>'>${i}</a></td>	
</c:forEach>
</c:if>
</body>
</html>